package com.jd.jobkeeper.client;

import com.jd.jobkeeper.protocals.Task;

public class TaskContext {

    final Task task;
    private volatile boolean isInterrupted = false;
    private int status;
    private String msg;



    public long taskId() {
        return task.getId();
    }

    public long jobId(){
        return task.getJobId();
    }


    public String name() {
        return task.getName();
    }

    public String parameter(){
        return task.getParameter();
    }

    public TaskContext(Task task) {
        this.task = task;
    }

    Task task() {
        return task;
    }

    public void interrupt() {
        synchronized (this) {
            isInterrupted = true;
        }
    }

    public void exception(Throwable t) {
    }

    public boolean isInterrupted() {
        return isInterrupted;
    }

    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("taskId:").append(task.getId()).append(',');
        sb.append("name:").append(task.getName());
        return sb.toString();
    }
}
